// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.skinnedmodel.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.lwjgl.util.vector.Matrix4f;
import zombie.core.skinnedmodel.animation.AnimationClip;

public final class SkinningData {
    public HashMap<String, AnimationClip> AnimationClips;
    public List<Matrix4f> BindPose;
    public List<Matrix4f> InverseBindPose;
    public List<Matrix4f> BoneOffset = new ArrayList();
    public List<Integer> SkeletonHierarchy;
    public HashMap<String, Integer> BoneIndices;
    private SkinningBoneHierarchy m_boneHieararchy = null;

    public SkinningData(
        HashMap<String, AnimationClip> animationClips,
        List<Matrix4f> bindPose,
        List<Matrix4f> inverseBindPose,
        List<Matrix4f> skinOffset,
        List<Integer> skeletonHierarchy,
        HashMap<String, Integer> boneIndices
    ) {
        this.AnimationClips = animationClips;
        this.BindPose = bindPose;
        this.InverseBindPose = inverseBindPose;
        this.SkeletonHierarchy = skeletonHierarchy;

        for (int _int = 0; _int < skeletonHierarchy.size(); _int++) {
            Matrix4f matrix4f = (Matrix4f)skinOffset.get(_int);
            this.BoneOffset.add(matrix4f);
        }

        this.BoneIndices = boneIndices;
    }

    private void validateBoneHierarchy() {
        if (this.m_boneHieararchy == null) {
            this.m_boneHieararchy = new SkinningBoneHierarchy();
            this.m_boneHieararchy.buildBoneHiearchy(this);
        }
    }

    public int numBones() {
        return this.SkeletonHierarchy.size();
    }

    public int numRootBones() {
        return this.getBoneHieararchy().numRootBones();
    }

    public int getParentBoneIdx(int boneIdx) {
        return (Integer)this.SkeletonHierarchy.get(boneIdx);
    }

    public SkinningBone getBoneAt(int boneIdx) {
        return this.getBoneHieararchy().getBoneAt(boneIdx);
    }

    public SkinningBone getBone(String boneName) {
        Integer integer = (Integer)this.BoneIndices.get(boneName);
        return integer == null ? null : this.getBoneAt(integer);
    }

    public SkinningBone getRootBoneAt(int idx) {
        return this.getBoneHieararchy().getRootBoneAt(idx);
    }

    public SkinningBoneHierarchy getBoneHieararchy() {
        this.validateBoneHierarchy();
        return this.m_boneHieararchy;
    }
}
